<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    li {
        list-style: none;
    }

    .active {
        color: red;
    }

    .line {
        font-weight: bold;
    }
</style>

<body>
    <div id="app">
        <ul>
            <!-- :class={k1:v1,k2:v2,k3,v3}  -->
            <!-- K(类名) : boolean值    ||  如果boolean值为true，该类名会加在标签中，如果为false则不会  -->
            <li class="title" :class="{active:actived,line:isline}">第一个</li>
            <button  @click="liclick">按钮</button>
            <li class="title" :class="getClass()">第二个</li>
        </ul>
    </div>
</body>
<script src="../js/http_cdn.bootcdn.net_ajax_libs_vue_2.6.6_vue.js"></script>
<script>
    new Vue({
        el: "#app",
        data: {
            msg: "你好",
            actived: true,
            isline: true
        },
        methods: {
            liclick() {
                this.actived = !this.actived
                this.isline = !this.isline
            },
            getClass(){
                return {active:this.actived,line:this.isline}
            }
        },
    })
</script>

</html>
